<extend name="Common/common"/>
<block name="main">
	 <div class="aui-content aui-margin-b-15">
         <form id="myForm">
    <ul class="aui-list">
            <li class="aui-list-item digdetail-li">
                <div class="aui-list-item-inner">
                    姓名<span class="me-diagde-span">
                    <input type="text" class="input-text" name="name" value="{$userinfo['name']}" required id="name" style="text-align: right;">
                  </span>
                </div>
            </li>
            <li class="aui-list-item digdetail-li">
                <div class="aui-list-item-inner">
                    身份证<span class="me-diagde-span">
                      <input type="text" class="input-text" name="idcard" value="{$userinfo['idcard']}" style="text-align: right;" required id="idcard" >
                    </span>
                </div>
            </li>
            <li class="aui-list-item digdetail-li">
                <div class="aui-list-item-inner">
                    性别
                    <span class="me-diagde-span">
                        <label><input type="radio" name="sex" value="0" <if condition="$userinfo['sex'] eq 0">checked="checked"</if> /> 女</label> &nbsp;
                        <label><input type="radio" name="sex" value="1" <if condition="$userinfo['sex'] eq 1">checked="checked"</if> />  男</label>
                    </span>
                </div>
            </li>
            <li class="aui-list-item digdetail-li">
                <div class="aui-list-item-inner">
                    年龄<span class="me-diagde-span">
                     <input type="text" class="input-text" name="age" value="{$userinfo.age}" required id="age" style="text-align: right;">
                    </span>
                </div>
            </li>
            <li class="aui-list-item digdetail-li">
                <div class="aui-list-item-inner">
                    地址<span class="me-diagde-span">
                     <input type="text" class="input-text" name="address" value="{$userinfo.address}" style="text-align: right;" required id="address">
                  </span>
                </div>
            </li>
            <li class="aui-list-item digdetail-li">
                <div class="aui-list-item-inner">
                    手机号<span class="me-diagde-span">{$userinfo.mobile}</span>
                </div>
            </li>
            <li class="aui-list-item digdetail-li" >
                <div class="aui-list-item-inner" onclick="location.href='{:U('marriage',array('id'=>$id))}'">
                    婚育史<span class="me-diagde-span" id="obsterical_history" >{$userinfo.obsterical_history}</span>
                </div>
            </li>
             <li class="aui-list-item digdetail-li">
                <div class="aui-list-item-inner"  onclick="location.href='{:U('operationand_hurt',array('id'=>$id))}'">
                    手术和外伤<span class="me-diagde-span" id="operation_trauma" >{$userinfo.operation_trauma|msubstr=0,12}</span>
                </div>
            </li>
             <li class="aui-list-item digdetail-li">
                <div class="aui-list-item-inner" onclick="location.href='{:U('family_ill',array('id'=>$id))}'">
                    家族病史<span class="me-diagde-span"  id="family_history" >{$userinfo.family_history|msubstr=0,12}</span>
                </div>
            </li>
             <li class="aui-list-item digdetail-li">
                <div class="aui-list-item-inner" onclick="location.href='{:U('allergic_drug',array('id'=>$id))}'">
                    药物过敏<span class="me-diagde-span"  id="drug_allergy" >{$userinfo.drug_allergy|msubstr=0,12}</span>
                </div>
            </li>
             <li class="aui-list-item digdetail-li">
                <div class="aui-list-item-inner" onclick="location.href='{:U('foodand_contact',array('id'=>$id))}'">
                    食物和接触物过敏<span class="me-diagde-span" id="contact_allergy" >{$userinfo.contact_allergy|msubstr=0,12}</span>
                </div>
            </li>
        <li class="aui-list-item digdetail-li">
            <div class="aui-list-item-inner" onclick="location.href='{:U('person_accustomed',array('id'=>$id))}'">
                个人习惯<span class="me-diagde-span" id="habit" >{$userinfo.habit|msubstr=0,12}</span>
            </div>
        </li>
             <li class="aui-list-item digdetail-li">
                <div class="aui-list-item-inner"  onclick="location.href='{:U('comment',array('id'=>$id))}'">
                    备注<span class="me-diagde-span" id="remark" >{$userinfo.remark|msubstr=0,12}</span>
                </div>
            </li>
        </ul>
             </form>
    </div>
</block>
<block name="js">
    <!--引入js,css-->
    <script src="__STATIC__/form/jquery.validate.min.js"></script>
    <script src="__STATIC__/form/localization/messages_zh.min.js"></script>
    <script type="text/javascript" src="__STATIC__/common/js/user.js"></script>
    <script type="text/javascript">
        $(function(){
            var issend = false;
            //保存事件
            $('#add').click(function(){
                if(issend) return false;
                issend = true;
                //验证年龄
                var age = $.trim($('#age').val());
                if(/^\d{1,3}$/.test(age)==false){
                    layer_msg('年龄不合法');
                    issend = false;
                    return false;
                }
                //验证姓名
                var name = $.trim($('#name').val());
                if(name.length>10){
                    layer_msg('姓名超过最大字符');
                    issend = false;
                    return false;
                }
                //验证身份证
                var idcard = $.trim($('#idcard').val());
                if(/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(idcard)==false){
                    layer_msg('身份证号码不正确');
                    issend = false;
                    return false;
                }
                var mydata = $('#myForm').serialize();
                $.post(location.href,mydata,function (data){
                    issend = false;
                    if(data.code==0){
                        layer_msg('已保存');
                        location.href=data.url;
                    }
                    else{
                        layer_msg('保存失败，请稍候再试！');
                    }
                },'json');
            });


            setInterval(function(){
                jQuery.ajax({
                    type:"POST",
                    url:"{:U('ajax_person_info')}",
                    global:false,
                    dataType:"json",
                    data:"action=ajax",
                    success:function(data){
                        if(data.obsterical_history){
                            $("#obsterical_history").text(data.obsterical_history);
                        }
                        if(data.operation_trauma){
                            $("#operation_trauma").text(data.operation_trauma);
                        }
                        if(data.contact_allergy){
                            $("#contact_allergy").text(data.contact_allergy);
                        }
                        if(data.drug_allergy){
                            $("#drug_allergy").text(data.drug_allergy);
                        }
                        if(data.family_history){
                            $("#family_history").text(data.family_history);
                        }
                        if(data.habit){
                            $("#habit").text(data.habit);
                        }
                        if(data.remark){
                            $("#remark").text(data.remark);
                        }

                    },
                    error:function()
                    {

                    }
                })
            }, 1000);
        });

    </script>
</block>